package vip.specimen.system.datasource.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;

/**
 * *@Author: 余浪人
 * *@Date：2021/3/10 14:37
 * *@Email:yulangren520@Gmail.com
 * *@QQ:1368419640
 **/
@Getter
@Setter
@Entity
@Table(name = "system_resource_suffix")
public class SystemResourceSuffixEntity extends BaseEntity {
    @Column(unique = true, nullable = false, updatable = false)
    @ApiModelProperty(value = "后缀")
    private String suffix;
    @ApiModelProperty(value = "状态")
    private boolean enable = Boolean.TRUE;
    @ApiModelProperty(value = "资源分类", dataType = "SystemResourceKindEntity")
    @ManyToOne(targetEntity = SystemResourceKindEntity.class, fetch = FetchType.LAZY)
    @JsonIgnore
    @JoinTable(name = "system_suffix_kind", joinColumns = @JoinColumn(name = "system_suffix_uuid"), inverseJoinColumns = @JoinColumn(name = "system_kind_uuid"))
    private SystemResourceKindEntity kindEntity;

    public SystemResourceSuffixEntity() {
    }

    public SystemResourceSuffixEntity(String suffix) {
        this.suffix = suffix;
    }

    @Override
    public String toString() {
        return "SystemResourceSuffixEntity{" +
                "suffix='" + suffix + '\'' +
                ", enable=" + enable +
                ", kindEntity=" + kindEntity +
                '}';
    }
}
